#[derive(PartialEq, Debug)]
struct CloneDemo {}

pub fn search_one<'a>(query: &str, contents: &'a str) -> Vec<&'a str> {
    let mut result = Vec::new();
    for line in contents.lines() {
        if line.contains(query) {
            result.push(line);
        }
    }
    return result;
}

pub fn search_two<'a>(query: &str, contents: &'a str) -> Vec<&'a str> {
    return contents.lines().filter(|line| line.contains(query)).collect();
}

#[test]
fn search_test() {
    let query = "abc";
    let contents = "abc edfdfdsfd sddf adc";

    let vec_one = search_one(query, contents);
    println!("vec_one's size is {}", vec_one.len());

    let vec_two = search_two(query, contents);
    println!("vec_two's size is {}", vec_two.len());
}
